home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3896 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: news.bridge.net!news
  2. From: David Byrden <100101.2547@compuserve.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Copy constructing an already default constructed object
  5. Date: 26 Jan 1996 14:36:00 GMT
  6. Organization: self-employed
  7. Message-ID: <4eaosg$ab7@news.bridge.net>
  8. References: <4e906b$stk@elaine32.Stanford.EDU>
  9. NNTP-Posting-Host: ppp-mia1-49.bridge.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
  14.  
  15.  
  16. >> I'd like to know what people think of the solution I've reached.
  17.  
  18. No offence, but you genuinely do not know what you are doing. I recommend 
  19. some serious study of worked examples of C++.
  20.  
  21. For example, you should never use memcpy to copy C++ objects. There are 
  22. many reasons.
  23.  
  24. I simply can't understand why it is that you won't write an assignment 
  25. operator like this;
  26.  
  27. A& operator=( const A&* other )
  28. {
  29.     return if assigning self to self
  30.     do what the dtor does
  31.     do what the copy ctor does
  32.     return *this
  33. }
  34.  
  35.  
  36. This is the basic model for an assignment operator, although it usually 
  37. can be internally optimised
  38.  
  39.  
  40. >> I figure that this type of shit is common enough
  41.  
  42. C++ is not the only language where you need improvements.
  43.  
  44.  
  45.                David
  46.  
  47.  
  48.